# -*- coding: utf-8 -*-
# @Time : 2021/9/16 22:18
# @Author : Mr  jelis
# @Email : 1402615849@qq.com
# @File : MRSX-ST-CUXIAO-004.py
# @Project : app_test
"""秒杀活动商品加入购物车"""
from appium import webdriver
from appium.webdriver.common.mobileby import MobileBy as By
from time import sleep
from model.huadong import HuaDong
desired_capabilities={
    "platformName":"Android",
    "deviceName":"127.0.0.1:62001",
    "platformVersion":"7.1.2",
    "appPackage":" cn.missfresh.application",
    "appActivity":"cn.missfresh.module.main.view.MainActivity",
    "noReset":True
}
driver=webdriver.Remote("http://localhost:4723/wd/hub",desired_capabilities)

miaosha_locator=(By.XPATH,'/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/'
                          'android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/'
                          'android.widget.RelativeLayout/android.widget.FrameLayout/android.view.ViewGroup/'
                          'android.widget.FrameLayout/androidx.recyclerview.widget.RecyclerView/android.widget.RelativeLayout[2]/'
                          'androidx.recyclerview.widget.RecyclerView/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/'
                          'android.widget.FrameLayout/android.widget.ImageView')
qianggou_locator=(By.XPATH,'/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/'
                           'android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/'
                           'android.widget.FrameLayout[2]/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/'
                           'android.webkit.WebView/android.webkit.WebView/android.view.View/android.view.View/android.view.View[1]/'
                           'android.view.View[2]/android.view.View[6]/android.view.View')
hd=HuaDong(driver)
hd.down_hua()
driver.find_element(*miaosha_locator).click()
sleep(3)
driver.find_element(*qianggou_locator).click()
sleep(10)
driver.quit()

